#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const int N=1e5+10;
ll n,m,l;
ld vl;
ld d[N],v[N],a[N];
int ans1,ans;
int cs[N];

bool check(int x,int cc){
    bool f=0;
    ld l=0.0,r=0.0;
    if(a[x]>0){
        ld t=vl-v[x];
        t/=a[x];
        l=d[x]+t*v[x]+0.5*t*t*a[x];
        for(int i=m;i>=1;i--)if(cs[i]>l&&((1<<(i-1))&cc))return 1;
    }
    else if(a[x]<0){
        ld t=vl-v[x];
        t/=a[x];
        if(v[x]<=vl)return 0;
        l=d[x],r=d[x]+v[x]*t+0.5*t*t*a[x];
        for(int i=1;i<=m;i++)if(cs[i]>=l&&cs[i]<r&&((1<<(i-1))&cc))return 1;

    }else if(v[x]>vl){
        for(int i=m;i>=1;i--)if(d[x]<=cs[i]&&((1<<(i-1))&cc))return 1;
    }
    return 0;
}

void sol1(int x){
    int cnt=0,tt=x;
    while(tt){
        if(tt&1)cnt++;
        tt>>=1;
    }if(cnt>=ans)return;
    int tmp=0;
    for(int i=1;i<=n;i++){
        if(check(i,x))tmp++;
    }cnt=INT_MAX;
    if(tmp==ans1){
     //   cout<<x<<' ';
        cnt=0;
        while(x){
            if(x&1)cnt++;
            x>>=1;
        }
    }
    ans=min(ans,cnt);
}

int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    ios::sync_with_stdio(0);
    int T;
    cin>>T;
    while(T--){
        ans=INT_MAX;
        ans1=0;
        cin>>n>>m>>l>>vl;
        //if(n>=10000||m>=10000)return 0;
        for(int i=1;i<=n;i++)
            cin>>d[i]>>v[i]>>a[i];
        for(int i=1;i<=m;i++)cin>>cs[i];
        for(int i=1;i<=n;i++)if(check(i,(1<<m)-1))ans1++;
        cout<<ans1<<' ';
    //    cout<<'\n';
        if(m<=20){
            for(int i=0;i<(1<<m);i++){
                sol1(i);
            }//cout<<'\n';
            cout<<m-ans;
        }
        else {
                if(ans1)cout<<m-1;
                else cout<<m;
        }
        cout<<'\n';
    }
    return 0;
}
/*

*/
